/**
  * @author Jadic
  * @created 2012-8-10 
  */
 package learn.netty.udp;
 
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.ExceptionEvent;
 import org.jboss.netty.channel.MessageEvent;
 import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
 
 /**
  * @author Jadic
  *
  */
 public class UdpEventHandler extends SimpleChannelUpstreamHandler {
     
     private void log(Object msg) {
         System.out.println(msg);
     }
 
     @Override
     public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
             throws Exception {
         log("messageReceived");
         ChannelBuffer buffer = (ChannelBuffer)e.getMessage();
         byte[] recByte=buffer.copy().toByteBuffer().array();
         log(new String(recByte));
     }
 
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
             throws Exception {
         log("exceptionCaught");
     }
 
 }